#include <iostream>
#include <unistd.h>
#include <pthread.h>
#include <string>

void* thread_function(void* args)
{
    pthread_detach(pthread_self());//子线程去分离父线程
    int cnt = 5;
    while(cnt--)
    {
        std::cout << cnt << std::endl;
    }
    return nullptr;
}

int main()
{
    pthread_t tid;
    pthread_create(&tid, nullptr, thread_function, (void*)"thread_1");
    //pthread_detach(tid);//父线程分离子线程
    int cnt = 5;
    while(cnt--)
    {
        std::cout << cnt + 10 << std::endl;
    }
    pthread_join(tid, nullptr);
    return 0;
}